278. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2021-05-13 09:09:05 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

278.1 Files compared

#LocationFileLast Modified
12021-05-13 09:09:05 +0000
2/Applications/Ampps/www/Porto v4.0.0/Theme Files/Magento 2.x/Porto Theme/app/design/frontend/Smartwave/porto/Mageplaza_LayeredNavigation/web/jslayer.js2021-02-17 02:25:12 +0000

278.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged00
Changed00
Inserted1313
Removed00

278.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

278.4 Active regular expressions

No regular expressions were active.

278.5 Comparison detail

    1 /**
    2  * Copyright 2016 Mageplaza. All rights reserved.
    3  * See https://www.mageplaza.com/LICENSE.txt for license details.
    4  */
    5 define([
    6     'jquery',
    7     'productListToolbarForm'
    8 ], function ($) {
    9     "use strict";
    10     var next_page = "";
    11     var loading = false;
    12     var infinite_loaded_count = 0;
    13     var active = false;
    14     $.widget('mageplaza.layer', {
    15 
    16         options: {
    17             productsListSelector: '#layer-product-list',
    18             navigationSelector: '#layered-filter-block'
    19         },
    20 
    21         _create: function () {
    22             this.initProductListUrl();
    23             this.initObserve();
    24             this.initLoading();
    25             this.inFinite();
    26         },
    27 
    28         initProductListUrl: function () {
    29             var self = this;
    30             $.mage.productListToolbarForm.prototype.changeUrl = function (paramName, paramValue, defaultValue) {
    31                 var urlPaths = this.options.url.split('?'),
    32                     baseUrl = urlPaths[0],
    33                     urlParams = urlPaths[1] ? urlPaths[1].split('&') : [],
    34                     paramData = {},
    35                     parameters;
    36                 for (var i = 0; i < urlParams.length; i++) {
    37                     parameters = urlParams[i].split('=');
    38                     paramData[parameters[0]] = parameters[1] !== undefined
    39                         ? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20'))
    40                         : '';
    41                 }
    42                 paramData[paramName] = paramValue;
    43                 if (paramValue == defaultValue) {
    44                     delete paramData[paramName];
    45                 }
    46                 paramData = $.param(paramData);
    47 
    48                 self.ajaxSubmit(baseUrl + (paramData.length ? '?' + paramData : ''));
    49             }
    50         },
    51 
    52         initObserve: function () {
    53             var self = this;
    54             var aElements = this.element.find('a');
    55             aElements.each(function (index) {
    56                 var el = $(this);
    57                 var link = self.checkUrl(el.prop('href'));
    58                 if(!link) return;
    59 
    60                 el.bind('click', function (e) {
    61                     if (el.hasClass('swatch-option-link-layered')) {
    62                         var childEl = el.find('.swatch-option');
    63                         childEl.addClass('selected');
    64                     } else {
    65                         var checkboxEl = el.find('input[type=checkbox]');
    66                         checkboxEl.prop('checked', !checkboxEl.prop('checked'));
    67                     }
    68 
    69                     self.ajaxSubmit(link);
    70                     e.stopPropagation();
    71                     e.preventDefault();
    72                 });
    73 
    74                 var checkbox = el.find('input[type=checkbox]');
    75                 checkbox.bind('click', function (e) {
    76                     self.ajaxSubmit(link);
    77                     e.stopPropagation();
    78                 });
    79             });
    80 
    81             $(".filter-current a").bind('click', function (e) {
    82                 var link = self.checkUrl($(this).prop('href'));
    83                 if(!link) return;
    84 
    85                 self.ajaxSubmit(link);
    86                 e.stopPropagation();
    87                 e.preventDefault();
    88             });
    89 
    90             $(".filter-actions a").bind('click', function (e) {
    91                 var link = self.checkUrl($(this).prop('href'));
    92                 if(!link) return;
    93 
    94                 self.ajaxSubmit(link);
    95                 e.stopPropagation();
    96                 e.preventDefault();
    97             });
    98         },
    99 
    100         checkUrl: function (url) {
    101             var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
    102 
    103             return regex.test(url) ? url : null;
    104         },
    105 
    106         initLoading: function () {
    107 
    108         },
    109 
    110         inFinite: function() {
    111             var self = this;
    112             next_page = "";
    113             if($(self.options.productsListSelector +' .infinite-loader').length > 0){
    114                 active = true;
    115             }
    116             $(".pages-items li > a.next").each(function(){
    117                 next_page = $(this).attr("href");
    118             });
    119             $(window).scroll(function(){
    120                 if(!loading && next_page && active && $(window).scrollTop() >= $(".infinite-loader").offset().top-$(window).height()+100){
    121                     if(infinite_loaded_count < 2){
    122                         loading = true;
    123                         $(".pages-items li > a.next").each(function(){
    124                             next_page = $(this).attr("href");
    125                         });
    126                         self.ajaxInfinite(next_page);
    127                     }
    128                 }
    129             });
    130             $(".infinite-loader .btn-load-more").click(function(){
    131                 if(!loading && next_page && infinite_loaded_count >= 2){
    132                     loading = true;
    133                     self.ajaxInfinite(next_page);
    134                 }
    135             });
    136         },
    137 
    138         ajaxInfinite: function (submitUrl) {
    139             var self = this;
    140             infinite_loaded_count++;
    141             $('.infinite-loader .btn-load-more').hide();
    142             $('.infinite-loader .loading').hide();
    143             $.ajax({
    144                 url: submitUrl,
    145                 data: {isAjax: 1},
    146                 type: 'post',
    147                 dataType: 'json',
    148                 beforeSend: function () {
    149                     $('.infinite-loader .btn-load-more').hide();
    150                     $('.infinite-loader .loading').show();
    151                 },
    152                 success: function (res) {
    153                     loading = false;
    154                     if (res.backUrl) {
    155                         window.location = res.backUrl;
    156                         return;
    157                     }
    158                     if (res.products) {
    159                         if($(res.products).find('div.products-grid')){
    160                             var items_grid = $(res.products).find('div.products-grid.wrapper .product-items .item');
    161                             $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_grid);
    162                             $(self.options.productsListSelector).trigger('contentUpdated');
    163                         }
    164                         if($(res.products).find('div.products-list')){
    165                             var items_list = $(res.products).find('div.products-list.wrapper .product-items .item');
    166                             $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_list);
    167                             $(self.options.productsListSelector).trigger('contentUpdated');
    168                         }
    169                         if($(res.products).find('.pages a.next').length > 0){
    170                             $(self.options.productsListSelector + ' .pages a.next').attr('href', $(res.products).find('.pages a.next').attr('href'));
    171                         }else{
    172                             $(self.options.productsListSelector + ' .pages a.next').remove();
    173                         }
    174                         if($("form[data-role=tocart-form]").length > 0) {
    175                             $("form[data-role=tocart-form]").catalogAddToCart();
    176                         }
    177                         $('.main .products.grid .product-items li.product-item:nth-child(2n)').addClass('nth-child-2n');
    178                         $('.main .products.grid .product-items li.product-item:nth-child(2n+1)').addClass('nth-child-2np1');
    179                         $('.main .products.grid .product-items li.product-item:nth-child(3n)').addClass('nth-child-3n');
    180                         $('.main .products.grid .product-items li.product-item:nth-child(3n+1)').addClass('nth-child-3np1');
    181                         $('.main .products.grid .product-items li.product-item:nth-child(4n)').addClass('nth-child-4n');
    182                         $('.main .products.grid .product-items li.product-item:nth-child(4n+1)').addClass('nth-child-4np1');
    183                         $('.main .products.grid .product-items li.product-item:nth-child(5n)').addClass('nth-child-5n');
    184                         $('.main .products.grid .product-items li.product-item:nth-child(5n+1)').addClass('nth-child-5np1');
    185                         $('.main .products.grid .product-items li.product-item:nth-child(6n)').addClass('nth-child-6n');
    186                         $('.main .products.grid .product-items li.product-item:nth-child(6n+1)').addClass('nth-child-6np1');
    187                         $('.main .products.grid .product-items li.product-item:nth-child(7n)').addClass('nth-child-7n');
    188                         $('.main .products.grid .product-items li.product-item:nth-child(7n+1)').addClass('nth-child-7np1');
    189                         $('.main .products.grid .product-items li.product-item:nth-child(8n)').addClass('nth-child-8n');
    190                         $('.main .products.grid .product-items li.product-item:nth-child(8n+1)').addClass('nth-child-8np1');
    191                         var hist = submitUrl;
    192                         if(submitUrl.indexOf("p=") > -1){
    193                             var len = submitUrl.length-submitUrl.indexOf("p=");
    194                             var str_temp = submitUrl.substr(submitUrl.indexOf("p="),len);
    195                             var page_param = "";
    196                             if(str_temp.indexOf("&") == -1){
    197                                 page_param = str_temp;
    198                             } else {
    199                                 page_param = str_temp.substr(0,str_temp.indexOf("&"));
    200                             }
    201                             hist = submitUrl.replace(page_param, "");
    202                         }
    203                         if (typeof window.history.pushState === 'function') {
    204                             window.history.pushState({url: hist}, '', hist);
    205                         }
    206                         if(typeof enable_quickview != 'undefined' && enable_quickview == true) {
    207                             requirejs(['jquery', 'weltpixel_quickview' ],
    208                                 function($, quickview) {
    209                                     $('.weltpixel-quickview').off('click').on('click', function() {
    210                                         var prodUrl = $(this).attr('data-quickview-url');
    211                                         if (prodUrl.length) {
    212                                             quickview.displayContent(prodUrl);
    213                                         }
    214                                     });
    215                                 });
    216                         }
    217                         $(".products-grid .weltpixel-quickview").each(function(){
    218                             $(this).appendTo($(this).parent().parent().children(".product-item-photo"));
    219                         });
    220                         $("#layer-product-list img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"});
    221                         if ($('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) {
    222                             $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('initialized.owl.carousel', function() {
    223                                 $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear');
    224                             });
    225                             $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() {
    226                                 $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear');
    227                             });
    228                         }
    229                         next_page = "";
    230                         $(".pages-items li > a.next").each(function(){
    231                             next_page = $(this).attr("href");
    232                         });
    233                         if(infinite_loaded_count >= 2){
    234                             $('.infinite-loader .loading').hide();
    235                             if(next_page){
    236                                 $('.infinite-loader .btn-load-more').show();
    237                                 $(".infinite-loader .btn-load-more").unbind("click").click(function(){
    238                                     if(!loading && next_page && infinite_loaded_count >= 2){
    239                                         loading = true;
    240                                         self.ajaxInfinite(next_page);
    241                                     }
    242                                 });
    243                             }
    244                         } else {
    245                             $('.infinite-loader .loading').fadeOut(300);
    246                         }
    247                     }
    248 
    249                 },
    250                 error: function () {
    251                     window.location.reload();
    252                 }
    253             });
    254         },
    255 
    256         ajaxSubmit: function (submitUrl) {
    257             var self = this;
    258             infinite_loaded_count = 0;
    259             $.ajax({
    260                 url: submitUrl,
    261                 data: {isAjax: 1},
    262                 type: 'post',
    263                 dataType: 'json',
    264                 beforeSend: function () {
    265                     $('.ln_overlay').show();
    266                     if (typeof window.history.pushState === 'function') {
    267                         window.history.pushState({url: submitUrl}, '', submitUrl);
    268                     }
    269                 },
    270                 success: function (res) {
    271                     if (res.backUrl) {
    272                         window.location = res.backUrl;
    273                         return;
    274                     }
    275                     if (res.navigation) {
    276                         $(self.options.navigationSelector).replaceWith(res.navigation);
    277                         $(self.options.navigationSelector).trigger('contentUpdated');
    278                     }
    279                     if (res.products) {
    280                         $(self.options.productsListSelector).replaceWith(res.products);
    281                         $(self.options.productsListSelector).trigger('contentUpdated');
    282                     }
    283                     $('.ln_overlay').hide();
    284                     if(typeof enable_quickview != 'undefined' && enable_quickview == true) {
    285                         requirejs(['jquery', 'weltpixel_quickview' ],
    286                         function($, quickview) {
    287                             $('.weltpixel-quickview').off('click').on('click', function() {
    288                                 var prodUrl = $(this).attr('data-quickview-url');
    289                                 if (prodUrl.length) {
    290                                     quickview.displayContent(prodUrl);
    291                                 }
    292                             });
    293                         });
    294                     }
    295                     $(".products-grid .weltpixel-quickview").each(function(){
    296                         $(this).appendTo($(this).parent().parent().children(".product-item-photo"));
    297                     });
    298                     $("#layer-product-list img.porto-lazyload").lazyload({effect:"fadeIn"});
    299                     if ($('#layer-product-list .porto-lazyload').closest('.owl-carousel').length) {
    300                         $('#layer-product-list .porto-lazyload').closest('.owl-carousel').on('changed.owl.carousel', function() {
    301                             $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear');
    302                         });
    303                     }
    304                 },
    305                 error: function () {
    306                     window.location.reload();
    307                 }
    308             });
    309         }
    310     });
    311 
    312     return $.mageplaza.layer;
    313 });